package com.tanhua.server.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.tanhua.dubbo.server.api.RecommendUserApi;
import com.tanhua.dubbo.server.pojo.RecommendUser;
import com.tanhua.dubbo.server.vo.PageInfo;
import com.tanhua.server.vo.TodayBest;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @Auther: you
 * @Date: 2021/05/29/20:41
 * @Description:
 */

/**
 * 负责与dubbo服务进行交互
 */
@Service
public class RecommendUserService {
    @Reference(version = "1.0.0")
    private RecommendUserApi recommendUserApi;


    public TodayBest queryTodayBest(Long userId){

            RecommendUser recommendUser = recommendUserApi.queryWithMaxScore(userId);
            if (recommendUser==null){
                return null;
            }

            TodayBest todayBest = new TodayBest();
            //填充TodayBest
            //编号
            todayBest.setId(recommendUser.getUserId());

            //缘分值（double:向下取整 99.8-->99）
            double score = Math.floor(recommendUser.getScore());
            long l = Double.valueOf(score).longValue();
            Integer i=(int)l;
            todayBest.setFateValue(i);

            return todayBest;

    }

    public PageInfo<RecommendUser> queryRecommendation(Long userId,Integer pageNum ,Integer pageSize) {
        return recommendUserApi.queryPageInfo(userId, pageNum, pageSize);
    }
}
